<import file="js.jquery#chained"/>
<import file="js.maskedinput"/>
<ol class="breadcrumb" >
    <li><i class="fa fa-anchor"></i>
        &nbsp;电桩管理
    </li>
    <li>修改电桩信息</li>
</ol>
<div class="panel panel-mcit">
    <div class="panel-body" id="container">
        <div class="col-xs-12 info-center" style=" margin-top: 0px;">
            <div class="unit_info" id="unit_info" style="margin-right: 5%;">
                <div class="clearfix"></div>
                <div class="col-xs-12">
                    <div class="panel-group" id="accordion">
                        <div class="panel panel-mcit" >
                            <div class="panel-heading"data-toggle="collapse" data-parent="#accordion"
                                 href="#collapse1" style="cursor: pointer;" >
                                <h4 class="panel-title" align="center">
                                    批量修改电桩所属站点
                                    <a data-toggle="collapse" data-toggle="collapse" data-parent="#accordion"
                                       href="#collapse1"  id="">
                                    </a>
                                </h4>
                            </div>
                            <div id="collapse1" class="panel-collapse collapse in">
                                <div class="panel-body plant-body" align="center">
                                    <div class="col-xs-2 search-col">
                                        <div class="input-group">
                                            <span>　</span>
                                        </div>
                                    </div>
                                    <div style="margin-top: 10px; width: 1200px;">
                                        <div class="col-xs-6 search-col">
                                            <div class="input-group">
                                                <span class="input-group-addon" >所在地</span>
                                                <select id="location-f" name="location_f_1" class="form-control" style="width:130px;">
                                                    <option value="0">--</option>
                                                    <volist name="china" id="vo">
                                                        <option value="{$vo.code}">{$vo.name}</option>
                                                    </volist>
                                                </select>
                                                <select id="location-s" name="location_s_1" class="form-control" style="width:130px;border-left:0">
                                                    <option value="0">--</option>
                                                    <volist name="china" id="vo">
                                                        <volist name="vo['area']" id="vovo">
                                                            <option value="{$vovo.code}" class="{$vo.code}" >{$vovo.name}</option>
                                                        </volist>
                                                    </volist>
                                                </select>
                                                <select id="location-t" name="location_t_1" class="form-control " style="width:130px;border-left:0">
                                                    <option value="0">--</option>
                                                    <volist name="china" id="vo">
                                                        <volist name="vo['area']" id="vovo">
                                                            <volist name="vovo['area']" id="vovovo">
                                                                <option value="{$vovovo.code}" class="{$vovo.code}" >{$vovovo.name}</option>
                                                            </volist>
                                                        </volist>
                                                    </volist>
                                                </select>
                                                <button style="margin-left: 10px;"  class="btn btn-primary" id="SearchBtn"><i class="fa fa-search"></i>&nbsp;搜索
                                                </button>
                                            </div>
                                        </div>
                                    </div><div class="clearfix"></div>
                                    <label class=" control-label">搜索结果（点击名称进行选择）：</label>
                                    <div class=" alert-success" id="searchResult">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-8" align="center">
                <div class="form-group">
                    <div class="col-sm-offset-4 col-sm-8">
                        <a href="javascript:history.go(-1);" class="btn btn-warning"><i class="fa fa-mail-reply"></i>&nbsp;返回</a>
                    </div>
                </div>
            </div>
            <input class="hide" name="charids" id="charids"  value="{$_GET['charids']}">
        </div>
    </div>
</div>
<script>
    $(document).ready(function(){
        $("#location-s").chained("#location-f");
        $("#location-t").chained("#location-s");
        //搜索站点
        $("#SearchBtn").click(function () {
            $.post("__URL__/AjaxPlantSearch",
                    {
                        location_f_1: $("#location-f").val(),
                        location_s_1: $("#location-s").val(),
                        location_t_1: $("#location-t").val()
                    },
                    function (data, status) {
                        if (status == "success") {
                            $("#searchResult").html(data);
                        }
                    }
            );
        });
        $(".plant-body").on("click", '.siteSelect', function () {
            var plantId   = $(this).attr("data-nid");
            var plantName = $(this).text();
            var charids   = $("#charids").val();
            alertify.confirm("确定选择【"+plantName+"】吗？", function (e) {
                if (e) {
                    $.ajax({
                        type: "POST",
                        url:  '{:U("Evcharger/editplant")}',
                        data: {plantid:plantId,charids:charids},
                        dataType: "json",
                        success: function(data){
                            if(data.state==100){
                                location.href = data.url;
                            }else{
                                alertify.error(data.msg);
                            }
                        }
                    });
                } else {
                    alertify.error("取消操作！");
                }
            }, "mcit_default");
        });
    })
</script>